package com.itheima.handler;


import com.itheima.vo.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author :wujunjie
 * createTime :2022-12-28 19:08
 * description :
 */

@RestControllerAdvice
@Slf4j
public class GlobalExceptionHandler {
    //捕获运行时异常
    @ExceptionHandler(RuntimeException.class)
    public Result RuntimeHandler(RuntimeException e) {
        String message = e.getMessage();
//        log.error(message);
        e.printStackTrace();
        return Result.error(message);
    }
}

